package com.lawyer.drive.server;



import java.io.IOException;
import java.io.InputStream;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemIterator;
import org.apache.commons.fileupload.FileItemStream;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.commons.io.FilenameUtils;


public class DriverManager extends HttpServlet {

// temp


	  
	// more work
	  
	  /**
	 * 
	 */
	private static final long serialVersionUID = 6433017466561869274L;


	  
	@Override
	protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
		this.doPost(req, resp);
	}

	@Override
	protected void doPost(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
		
		try {
			
			 List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(req);
		        for (FileItem item : items) {
		            if (! item.isFormField()) {
		            	  // Process form file field (input type="file").
		                String fieldname = item.getFieldName();
		                String filename = FilenameUtils.getName(item.getName());
		                InputStream filecontent = item.getInputStream();
		                
		                
		                
		            } 
		        }
			
			
			
			
		
		} catch (final Exception e) {
			throw new ServletException(e);
		} finally {
			
		}
	}	 
	  
	  
	  
}
